/**
 * @param {number[][]} matches
 * @return {number[][]}
 */
 var findWinners = function(matches) {
  const win = new Map(), lose = new Map()
  for(const [x, y] of matches) {
    win.set(x, ~~win.get(x) + 1)
    lose.set(y, ~~lose.get(y) + 1)
  }
  let ans = [[],[]]
  for(const [k, v] of win) {
    if(!lose.has(k)) {
      ans[0].push(k)
    }
  }
  for(const [k, v] of lose) {
    if(v === 1) {
      ans[1].push(k)
    }
  }
  return ans.map(v => v.sort((a,b) => a-b))
};